package com.xs.controller;

import com.xs.common.R;
import com.xs.domain.Comment;
import com.xs.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 徐双
 * @ClassName CommentController
 * @date 2023-03-02 10:09
 * @Description:
 * @Version:1.0
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 新增评论
     * @param comment
     * @return
     */
    @PostMapping("/addComment")
    public R addComment(@RequestBody Comment comment){
        return commentService.insert(comment);
    }

    /**
     * 修改评论
     * @param comment
     * @return
     */
    @PostMapping("/updateComment")
    public R updateComment( @RequestBody Comment comment) {
       return commentService.updateComment(comment);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public R deleteComment(@RequestParam Integer id) {
        return commentService.deleteComment(id);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping("/delBatch")
    public R deleteBathIds(@RequestBody List<Integer> ids){
        System.out.println("test");
        return commentService.deleteBathIds(ids);
    }

    /**
     * 查询所有评论
     * @return
     */
    @GetMapping("/allComment")
    public R allComment() {
        return commentService.allComment();
    }

    /**
     * 查询某个乐谱下的所有评论
     * @param staffId
     * @return
     */
    @GetMapping("/commentOfStaffId")
    public R commentOfStaffId(@RequestParam Integer staffId) {
        return commentService.commentOfStaffId(staffId);
    }

    /**
     * 查询某个乐谱集下的所有评论
     * @param staffListId
     * @return
     */
    @GetMapping("/commentOfStaffListId")
    public R commentOfStaffListId(@RequestParam Integer staffListId) {
        return commentService.commentOfStaffListId(staffListId);
    }

}
